From b3c0cd671ac63992c3c14f236f8a2504f88c1ad3 Mon Sep 17 00:00:00 2001 From: robertl Date: Fri, 14 May 2004 17:54:47 +0000 Subject: [PATCH] Adds the container type and cache type to XCSV. --- gpsbabel/csv_util.c | 10 +++++++--- gpsbabel/gpx.c | 30 ++++++++++++++++++++++++++++-- gpsbabel/style/README.style | 28 ++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 5 deletions(-) diff --git a/gpsbabel/csv_util.c b/gpsbabel/csv_util.c index 3f577afec..826890826 100644 --- a/gpsbabel/csv_util.c +++ b/gpsbabel/csv_util.c @@ -801,9 +801,13 @@ xcsv_waypt_pr(const waypoint *wpt) /* Geocache Terrain as a double */ sprintf(buff, fmp->printfc, wpt->gc_data.terr / 10.0); } else - if (strcmp(fmp->key, "GEOCACHE_TYPE") == 0) { - /* Geocache Type TODO */ - sprintf(buff, fmp->printfc, "Geocache"); + if (strcmp(fmp->key, "GEOCACHE_CONTAINER") == 0) { + /* Geocache Container */ + sprintf(buff, fmp->printfc, gs_get_container(wpt->gc_data.container)); + } else + if (strcmp(fmp->key, "GEOCACHE_TYPE") == 0) { + /* Geocache Type */ + sprintf(buff, fmp->printfc, gs_get_cachetype(wpt->gc_data.type)); } else { /* this should probably never happen */ } diff --git a/gpsbabel/gpx.c b/gpsbabel/gpx.c index 0646688e5..5348dcdb4 100644 --- a/gpsbabel/gpx.c +++ b/gpsbabel/gpx.c @@ -468,7 +468,6 @@ gs_container_mapping{ { gc_virtual, "Virtual" } }; -static geocache_type gs_mktype(char *t) { @@ -483,7 +482,20 @@ gs_mktype(char *t) return gt_unknown; } -static +const char * +gs_get_cachetype(geocache_type t) +{ + int i; + int sz = sizeof(gs_type_map) / sizeof(gs_type_map[0]); + + for (i = 0; i < sz; i++) { + if (t == gs_type_map[i].type) { + return gs_type_map[i].name; + } + } + return "Unknown"; +} + geocache_container gs_mkcont(char *t) { @@ -498,6 +510,20 @@ gs_mkcont(char *t) return gc_unknown; } +const char * +gs_get_container(geocache_container t) +{ + int i; + int sz = sizeof(gs_container_map) / sizeof(gs_container_map[0]); + + for (i = 0; i < sz; i++) { + if (t == gs_container_map[i].type) { + return gs_type_map[i].name; + } + } + return "Unknown"; +} + static time_t xml_parse_time( char *cdatastr ) diff --git a/gpsbabel/style/README.style b/gpsbabel/style/README.style index 5f0152818..5deb5799c 100644 --- a/gpsbabel/style/README.style +++ b/gpsbabel/style/README.style @@ -301,6 +301,34 @@ The fields used by the XCSV parser are as follows: example: IFIELD TIMET_TIME,"","%ld" + o GEOCACHE_DIFF + GEOCACHE_DIFF is valid only for geocaches and represents a DOUBLE + PRECISION FLOAT. A "three and a half star" cache would therefore be "3.5" + + example: IFIELD GEOCACHE_DIFF,"","%3.1f" + + o GEOCACHE_TERR + GEOCACHE_TERR is valid only for geocaches and represents a DOUBLE + PRECISION FLOAT. A "three and a half star" cache would therefore be "3.5" + + example: IFIELD GEOCACHE_TERR,"","%3.1f" + + o GEOCACHE_CONTAINER + GEOCACHE_CONTAINER is valid only for geocaches and is heavily influenced + by the Groundspeak container types. Examples would include "Micro" + and "Virtual". + + example: GEOCACHE_CONTAINER,"","%s" + + o GEOCACHE_TYPE + GEOCACHE_TYPE is valid only for geocaches and is heavily influenced + by the Groundspeak cache types. Examples would include "Event cache" + and "Multi-Cache". + + example: GEOCACHE_TYPE,"","%s" + + + EXAMPLES: -------- -- 2.30.2